Add gtk_root_get_for_surface
authorMatthias Clasen <mclasen@redhat.com>
Sat, 23 Feb 2019 21:27:21 +0000 (16:27 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 24 Feb 2019 03:24:50 +0000 (22:24 -0500)
This is a replacement for gdk_surface_get_user_data.

gtk/gtkroot.c
gtk/gtkroot.h

index 1907786e956901072e71918982974c99d1a20b36..0a32288ba9ae2dd8c9a74bb5707eeec919a85bc6 100644 (file)
@@ -102,3 +102,24 @@ gtk_root_get_surface_transform (GtkRoot *self,
   iface = GTK_ROOT_GET_IFACE (self);
   return iface->get_surface_transform (self, x, y);
 }
+
+/**
+ * gtk_root_get_for_surface:
+ * @surface: a #GdkSurface
+ *
+ * Finds the GtkRoot associated with the surface.
+ * 
+ * Returns: (transfer none): the #GtkRoot that is associated with @surface
+ */
+GtkWidget *
+gtk_root_get_for_surface (GdkSurface *surface)
+{
+  gpointer user_data;
+
+  gdk_surface_get_user_data (surface, &user_data);
+
+  if (user_data && GTK_IS_ROOT (user_data))
+    return GTK_WIDGET (user_data);
+
+  return NULL;
+}
index e3494fcc7a3954753353ffb8dd061fc706face0c..45e777ba684e5d9ff755a09dc57539cdad998d47 100644 (file)
@@ -53,6 +53,8 @@ struct _GtkRootInterface
                                                          int                    *y);
 };
 
+GDK_AVAILABLE_IN_ALL
+GtkWidget * gtk_root_get_for_surface (GdkSurface *surface);
 
 G_END_DECLS